package app.enums;

import java.util.List;

/**
 *
 * @author Kseniya Artsiukhova <kartsiukhova@productiveedge.com>
 */
public enum PublicationTypeCode {

    BELLES_LETTRES("BLETT", "belles-lettres"),
    BUSINESS_LITERATURE("BUSLIT", "business literature"),
    CHILDRENS_LITERATURE("CHLIT", "children's literature"),
    COMPUTER_AND_SCIENCE("COMPSCIENCE", "computer & science"),
    OTHER("OTHER", "other");
    private String code;
    private String typeName;
    private List<GenreCode> genres;

    private PublicationTypeCode(String code, String typeName) {
        this.code = code;
        this.typeName = typeName;
    }

    public String getCode() {
        return code;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setGenres(List<GenreCode> genres) {
        this.genres = genres;
    }

    public List<GenreCode> getGenres() {
        return genres;
    }

    public static PublicationTypeCode getPublicationsTypeCodeByCode(String code) {
        PublicationTypeCode typeCode = null;
        
        for (PublicationTypeCode ptc : values()) {
            if (code.equals(ptc.getCode())) {
                typeCode = ptc;
            }
        }
        return typeCode;
    }

    public static PublicationTypeCode getPublicationsTypeCodeByTypeName(String typeName) {
        PublicationTypeCode typeCode = null;
        
        for (PublicationTypeCode ptc : values()) {
            if (typeName.equals(ptc.getTypeName())) {
                typeCode = ptc;
            }
        }
        return typeCode;
    }
}
